<cfmodule template="../../tag/layout.cfm" bodyIsEasyUILayout="false">
<cfscript>
	if( structKeyExists(rc, "id")  && rc.id > 0 ){
		id = rc.id;
	}else{
		id = 0;
	}
</cfscript>

<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
	body, html,#allmap {width: 100%;height:100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
</style>
<cfoutput><script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=#request.BaiduAK#"></script></cfoutput>
<div id="allmap"></div>
<form method="post" class="form">
<cfoutput>
<input name="id" type="hidden" value="#id#">
</cfoutput>
<input id="longitude" type="hidden" name="longitude">
<input id="latitude" type="hidden" name="latitude">
</form>
</cfmodule>
<script type="text/javascript">
	var closeDialog = function($dialog) {
		$dialog.dialog('destroy');
	}
	var submitForm = function($dialog, $grid) {
		url = '?action=store.update';
		console.log(fw.serializeObject($('form')));
		$.post(url, fw.serializeObject($('form')), function(result) {
			if (result) {
				$grid.datagrid('reload');
				$dialog.dialog('destroy');
			}
		}, 'json');
	};

</script>
<script type="text/javascript">
	$.ajax({
		    type: "POST",
		    url: "?action=store.get",
		    data: {
		        id:<cfoutput>#id#</cfoutput>
		    }
		}).done(function(result) {
			var map = new BMap.Map("allmap");
			var point = new BMap.Point(result.longitude,result.latitude);
			map.centerAndZoom(point, 12);
			var marker = new BMap.Marker(point);
			map.addOverlay(marker);
			map.enableScrollWheelZoom(true);
			marker.enableDragging();
			$('#longitude').val( point.lng);
			$('#latitude').val( point.lat );
			marker.addEventListener("dragend",function(e){
			    $('#longitude').val( e.point.lng );
				$('#latitude').val( e.point.lat );
			})
		})
</script>